package org.pb.system.service.impl;

import org.pb.basic.service.impl.BaseServiceImpl;
import org.pb.system.domain.SystemDictionaryDetail;
import org.pb.system.mapper.SysDicDetailMapper;
import org.pb.system.query.SystemDictionaryDetailQuery;
import org.pb.system.service.ISysDicDetailService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

/**
 * 数据字典明细对应的业务层实现类
 * @author
 */
@Service
public class SysDicDetailServiceImpl extends BaseServiceImpl<SystemDictionaryDetail, SystemDictionaryDetailQuery> implements ISysDicDetailService {

    @Autowired
    private SysDicDetailMapper sysDicDetailMapper;

    @Override
    @Transactional
    public void update(SystemDictionaryDetail condition) {
        if (condition == null || condition.getId() == null || condition.getType().getId() ==null) {
            throw new RuntimeException("条件不能为空");
        }
        // 将传入的参数中的type的id赋值给types_id
        condition.setTypes_id(condition.getType().getId());
        // 执行修改命令
        sysDicDetailMapper.update(condition);
    }

    @Override
    @Transactional
    public void save(SystemDictionaryDetail condition) {
        if (condition == null || condition.getType().getId() ==null) {
            throw new RuntimeException("条件不能为空");
        }
        // 将传入的参数中的type的id赋值给types_id
        condition.setTypes_id(condition.getType().getId());
        // 执行修改命令
        sysDicDetailMapper.save(condition);
    }
}
